<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改密码</title>
<link type="text/css" href="${staticResources}/css/sendemailver.css" rel="stylesheet" />
<script type="text/javascript" src="${staticResources}/js/ajax.js"></script>

<script type="text/javascript">
function changepassword()
{
	var password = document.getElementById("password").value;
	var newpassword = document.getElementById("newpassword").value;
	var newpassword2 = document.getElementById("newpassword2").value;
	var mode = "ajax";
	
	var params="password=" + encodeURIComponent(password);
	params+="&newpassword="+encodeURIComponent(newpassword);
	params+="&newpassword2="+encodeURIComponent(newpassword2);
	params+="&mode="+encodeURIComponent(mode);
	
	var checkid=document.getElementById("checkid");
	if(password.length==0) {
		checkid.innerHTML="<font color='red'> 旧密码不能为空！</font>";
		return;
	}
	if(newpassword.length==0) {
		checkid.innerHTML="<font color='red'> 新密码不能为空！</font>";
		return;
	}
	if(newpassword.length<6||newpassword.length>20) {
		checkid.innerHTML="<font color='red'> 新密码长度必须在6~20之间！</font>";
		return;
	}
	if(newpassword2.length==0) {
		checkid.innerHTML="<font color='red'> 确认密码不能为空！</font>";
		return;
	}
	if(newpassword != newpassword2) {
		checkid.innerHTML="<font color='red'> 两次输入的新密码不一致！</font>";
		return;
	}
	
	doAjax("ChangePassword"
			,params,function(rst){
	var rst=eval('(' +rst+ ')');
	if(rst.status == 0)
	{
		window.alert("密码修改成功！");
	}
	else 
	{
		window.alert(rst.message);
	} 
	});
}

</script>	
</head>
<body>
<div id="divmain" style=" background: url('${staticResources}/image/background.jpg');">
  <form method="post" action="ChangePassword" onsubmit="changepassword();return false;">
  <div id="divmessage">
    <label id="labelmessage">修改密码</label>
    <div id="divmessage_xq">
        <table id="tableform">
          <tr>
          <td class="tdtext"> 旧密码：</td>
          <td class="tdinput"> <input type="password" name="password" id="password"> </td>
          </tr>
        <tr height=10px></tr>
          <tr>
          <td class="tdtext"> 新密码：</td>
          <td class="tdinput"> <input type="password" name="newpassword" id="newpassword"> </td>
          </tr>
        <tr height=10px></tr>
         <tr>
          <td class="tdtext"> 确认新密码：</td>
          <td class="tdinput"> <input type="password" name="newpassword2" id="newpassword2"> </td>
          </tr>
        <tr height=10px></tr>
       </table>
       <div id="checkid"></div>
    </div>
  </div>
  <div id="divbottom">
    <input type="image" src="${staticResources}/image/submit.jpg" width="140" height="40" />
  </div>
  </form>
</div>
</body>
</html>